<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateContainersTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('containers', function(Blueprint $table)
		{
                    $table->engine = 'InnoDB';
                    $table->increments('id');
                    $table->string('name', 255)->index();
                    $table->integer('group_id')->references('id')->on('groups')->index();
                    $table->timestamps();            
		});

                Schema::table('items', function(Blueprint $table) 
                {
                    $table->integer('container_id')->references('id')->on('containers')->index();
                });

	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
            Schema::table('containers', function(Blueprint $table)
                {
                    Schema::drop('containers');            
                });
            Schema::table('items', function(Blueprint $table)
                {
                    Schema::dropForeign('container_id');
                });        
	}

}